var express = require("express");
const Redis = require("ioredis");

const redis = new Redis({
  port: 6379,
  host: "127.0.0.1",
  // username: "default",
  // password: "my-top-secret",
});
var router = express.Router();
const UserController = require("../../controllers/admin/user.controller");
const multer = require("multer");
// dest：要上传的文件夹
const upload = multer({ dest: "public/uploads/" });
/* GET users listing. */
router.get("/", async function (req, res, next) {
  // await redis.zadd("sortedSet", 1, "one", 2, "dos", 4, "quatro", 3, "three");
  // await redis.rpush("names", "changsha", "wuhan");
  await redis.set("user:1",)
  // await redis
  //   .multi()
  //   .set("key", "哈哈")
  //   .get("key")
  //   .exec((err, replies) => {
  //     replies.forEach((reply) => console.log(reply.toString()));
  //   });
  // await client.del("userInfo")]
  // await redis.hmset("userInfo", { gender: 0, password: "123456" });

  // const name = await client.type("username");
  // console.log(name);
  res.send("respond with a resource");
});

router.post("/admin/login", UserController.login);
// 当前接口标识的存储文件的字段为file
router.post("/admin/update", upload.single("file"), UserController.update);

module.exports = router;
